/**
 * @author LKQ
 * @date 2021/12/24 21:47
 * @description 递归
 */
public class Solution2 {
    public static void main(String[] args) {
        Solution2 s = new Solution2();
        System.out.println(s.addDigits1(38));
    }
    public int addDigits1(int num) {
        if (num < 10) {
            return num;
        }
        int ans = 0;
        while (num != 0) {
            int temp = num % 10;
            ans += temp;
            num /= 10;
        }
        return addDigits1(ans);
    }
}
